﻿//===============================================================================
// Microsoft Platform Architecture Team
// LitwareHR - S+S Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GeoRss;

namespace GeoRSSTest
{
    /// <summary>
    /// Summary description for TestPoint
    /// </summary>
    [TestClass]
    public class PointFixture
    {
        public PointFixture()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void BasicPointTest()
        {
            Point p = new Point(10, 11);

            Assert.AreEqual(p.Longitude, 11);
            Assert.AreEqual(p.Latitude, 10);
        }

        [TestMethod]
        public void PointToStringTest()
        {
            Point p = new Point(10, 11);

            Assert.AreEqual("10 11", p.ToString() );
        }

        [TestMethod]
        public void ParsesPoint()
        {
            Point p = Point.Parse("10.34 20.1");

            Assert.AreEqual("10.34 20.1", p.ToString());
            Assert.AreEqual(10.34, p.Latitude );
            Assert.AreEqual(20.1, p.Longitude);
        }

        [ExpectedException(typeof(ArgumentException))]
        [TestMethod]
        public void InsufficientCoordinatesThrow()
        {
            Point p = Point.Parse("10.34");
        }

        [ExpectedException(typeof(ArgumentException))]
        [TestMethod]
        public void TooManyCoordinatesThrow()
        {
            Point p = Point.Parse("10.34 10.34 98.43");
        }

        [ExpectedException(typeof(ArgumentException))]
        [TestMethod]
        public void NonNumberCoordinatesThrow()
        {
            Point p = Point.Parse("A 98.43");
        }
    }
}
